initDrugForm = function (){
	drugCompareForm = new DrugCompareForm();
};
var drug2code;
var drug1code;
var cityname;
var seasonselect;
DrugCompareForm = Ext.extend(Ext.FormPanel, {
	frame : false,
	id : 'compareForm',
	title:drugsComaprisonTitle,
	border : false,
	autoScroll : true,
	plain : true,
	bodyStyle : 'padding:5px',
	width : '90%',
	initComponent : function(config) {
	Ext.apply(this, {
		items : [{

			style : 'padding: 10px; font-size: 11; font-weight: bold',
			html : selectDrugTitle,
			border : false
		},
		{
			xtype : 'button',
			text : clearLabel,
			id: 'clearbtn',
			width: 90,
			disabled: true,
			cls : 'clearBtnCls',
			handler: function(b,e) {

			drugStore.removeAll();
			var combo1=Ext.getCmp('city');
			combo1.clearValue();
			var combo2=Ext.getCmp('month');
			combo2.clearValue();
			var combo3=Ext.getCmp('c1');
			combo3.clearValue();
			var combo4=Ext.getCmp('c2');
			combo4.clearValue();
			var btnClear=Ext.getCmp('clearbtn');
			btnClear.disable();
			var btnCmpr=Ext.getCmp('comparebtn');
			btnCmpr.disable();
			drug1code='';
			drug2code='';
			cityname='';
			seasonselect='';
		}
		},
		{
			xtype : 'combo',
			fieldLabel : cityLabel,
			id : 'city',
			selectOnFocus: true,
			triggerAction:'all',
			listWidth : 150,
			typeAhead: false,
			store: cityAll,
			mode : 'remote',
			displayField : comboDisplayField,
			allowBlank : false,
			valueField : '',
			hiddenName : '',
			emptyText: selectCityLabel,
			

			onKeyUp : function(){
			if(languageName=='arabic')
						this.store.filter("aName",this.getEl().dom.value,true,false);
					else
					this.store.filter("eName",this.getEl().dom.value,true,false);
this.onTriggerClick();
			
			this.show();
				
		},
		listeners: {
			'select': function(cmb, rec, idx){	
			cityname=rec.data.eName;
		}
		}
		},  
		{
			xtype : 'combo',
			fieldLabel : seasonLabel,
			id : 'month',
			selectOnFocus: true,
			triggerAction:'all',
			listWidth : 150,
			typeAhead: true,
		store: [allYearsValue, '1421', '1422', '1423','1424','1425','1426','1427','1428'],
			allowBlank : false,
			emptyText: selectSeasonLabel,

			listeners: {
			'select': function(cmb, rec, idx){	

			season=Ext.getCmp('month');
			seasonselect=season.getValue();
		}
		}
		},  
		{
			xtype : 'combo',
			fieldLabel : drug1Label,
			id : 'c1',
			selectOnFocus: true,
			triggerAction:'all',
			listWidth : 150,
			typeAhead: true,
			store: drugsAll,
			mode : 'remote',
			displayField : drugComboDisplayField,
			allowBlank : false,
			valueField : '',
			hiddenName : 'drug1Id',
			emptyText: selectDrugLabel,

			listeners: {
			'select': function(cmb, rec, idx){	

			if(languageName=='arabic'){
				drug1name = rec.data.adrugName;
			}else{
				drug1name = rec.data.drugName;
			}			
			drug1code = rec.data.drugCode;
			
			if(drug2code!=null && drug1code==drug2code){
				var combo3=Ext.getCmp('c1');
				combo3.clearValue();
				var btnCmpr=Ext.getCmp('comparebtn');
				btnCmpr.disable();
				Ext.Msg.alert(selectDifferentDrug);
			}else if(Ext.getCmp('c2').isValid()){
				var btnCmpr=Ext.getCmp('comparebtn');
				btnCmpr.enable();
			}
		}
		}
		},
		{
			xtype : 'combo',
			fieldLabel : drug2Label,
			id : 'c2',
			selectOnFocus: true,
			triggerAction:'all',
			listWidth : 150,
			typeAhead: true,
			store: drugsAll,
			mode : 'remote',
			displayField : drugComboDisplayField,
			allowBlank : false,
			valueField : '',
			hiddenName : 'drug2Id',
			emptyText: selectDrugLabel,

			listeners: {
			'select': function(cmb, rec, idx){	

			if(languageName=='arabic'){
				drug2name = rec.data.adrugName;
			}else{
				drug2name = rec.data.drugName;
			}			
			drug2code=rec.data.drugCode;

			if(drug1code!=null && drug1code==drug2code){
				var combo4=Ext.getCmp('c2');
				combo4.clearValue();
				var btnCmpr=Ext.getCmp('comparebtn');
				btnCmpr.disable();
				Ext.Msg.alert(selectDifferentDrug);
			}else if(Ext.getCmp('c1').isValid()){
				var btnCmpr=Ext.getCmp('comparebtn');
				btnCmpr.enable();
			}
			/*var btnCompare=Ext.getCmp('comparebtn');
	    		  btnCompare.enable();*/
		}
		}
		},
		{
			xtype : 'button',
				iconCls:'compbtnbg',
			
			width: 100,
			cls : 'compareButtonCls',
			id : 'comparebtn',
			disabled : true,
			listeners : {
			click : function() {
//drug1name = drug1code;
//drug2name = drug2code;


			
			/*var btnCompare=Ext.getCmp('comparebtn');
	    		  btnCompare.disable();*/
			
			var btnClear=Ext.getCmp('clearbtn');
			btnClear.enable();
			if(drug1name!='' && drug2name!='' && cityname!='' && seasonselect!='' && cityname!=null && seasonselect!=null){
			compareFormWindow = Ext.getCmp('compareFormWindow');
			if(compareFormWindow){


compareFormWindow.close();
			}

		
var chartForm= new ChartForm();
chartForm.getComponent('compareChart').store.baseParams = {drugcode1:drug1code, drugcode2:drug2code, adminName:cityname, monthName:seasonselect };
			chartForm.getComponent('compareChart').store.reload();
			
			compareFormWindow = new Ext.Window({
				width:500,
				height:300,
				id:'compareFormWindow',
				draggable: true,
				plain:false,
				layout: 'fit',
				border:true,
				resizable:false,
				shadow:false,
				frame:true,
				closeAction:'close'

			});
			
			compareFormWindow.setTitle(drug1name+' '+'/'+' '+drug2name+' '+comaprisonInLabel+' '+seasonselect );
			
			compareFormWindow.add(chartForm);
			compareFormWindow.doLayout();
		compareFormWindow.show();
		}	    	  
		}
		}
		}]
	});
	DrugCompareForm.superclass.initComponent.apply(this, arguments);
}
});